import request from "./request";

/**
 * 分页获取博客列表数据
 */
export async function getBlogs(page = 1, limit = 10, catgoryid = -1) {
  return await request.get("/api/blog", {
    params: {
      page,
      limit,
      catgoryid,
    }
  })
}
/**
 * 获取博客分类
 */
export async function getBlogTypes() {
  return await request.get("/api/blogType");
}
/**
 * 获取单篇博客
 * @param {*} id 
 * @returns 
 */
export async function getBlog(id) {
  return await request.get(`/api/blog/${id}`)
}
/**
 * 提交评论
 * @param {Object} commentInfo 
 * @returns 
 */
export async function postComment(commentInfo) {
  return await request.post(`/api/comment`, commentInfo);
}
/**
 * 分页获取评论
 */
export async function getComment(blogId, page = 1, limit = 10) {
  return await request.get("/api/comment", {
    params: {
      page,
      limit,
      blogId,
    }
  })
}